@page "/blog/list"

@using Blog.MVP.Blazor.SSR.Models

@inject HttpClient Http
@inject IJSRuntime JS
@inject BlogService BlogService

@attribute [Authorize]

<h1>博客</h1>

<p class="text-right">
    <a class="btn btn-primary" href="/blog/add">Add</a>
</p>

<table class="table">
    <tr>
        <th>Id</th>
        <th>标题</th>
        <th>外链</th>
        <th>阅读</th>
        <th></th>
    </tr>
    @if (_blogs != null)
    {
        foreach (var item in _blogs.response)
        {
            <tr>
                <td>@item.bID</td>
                <td>@item.btitle</td>
                <td>@item.bsubmitter</td>
                <td>@item.btraffic</td>
                <td>
                    <a class="btn btn-primary" href="/blog/modify/@item.bID">修改</a>
                </td>
            </tr>
        }
    }

</table>

@code {
    private MessageModel<List<BlogArticleVo>> _blogs;

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
             this._blogs = await BlogService.GetBlogs("MVP_2024|MVP_java_2023|MVP_aspnetcore_2023|MVP_java_2022|MVP_aspnetcore_2022|MVP_java_2021|MVP_aspnetcore_2021|MVP_bcvp_bloghigh|MVP_azure_2020|MVP_aspnetcore_2020|MVP_ids4_2020|MVP_blazor_2020");
            StateHasChanged();
        }
    }
}